Let shortname generator have access to full waypoint in case it wants
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Wed, 13 Apr 2005 03:20:36 +0000 (03:20 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Wed, 13 Apr 2005 03:20:36 +0000 (03:20 +0000)
to use extra fields in the decision-making process.   Not all formats
or callers converted yet.

19 files changed:
gpsbabel/Makefile
gpsbabel/cetus.c
gpsbabel/csv_util.c
gpsbabel/defs.h
gpsbabel/gpsutil.c
gpsbabel/gpx.c
gpsbabel/html.c
gpsbabel/lowranceusr.c
gpsbabel/magnav.c
gpsbabel/magproto.c
gpsbabel/mapsend.c
gpsbabel/mkshort.c
gpsbabel/ozi.c
gpsbabel/palmdoc.c
gpsbabel/pcx.c
gpsbabel/psp.c
gpsbabel/text.c
gpsbabel/tmpro.c
gpsbabel/tpg.c

index e74ab2f589d4fc8202196a1850604fcc06d823b6..600221e8a646ff2710951c0373a888aec24968ff 100644 (file)
@@ -90,10 +90,10 @@ dep:
        (echo -n "internal_styles.c: mkstyle.sh " ; echo style/*.style ; /bin/echo -e '\t./mkstyle.sh > internal_styles.c || (rm -f internal_styles.c ; exit 1)' ) >> /tmp/dep
        echo Edit Makefile and bring in /tmp/dep
 
-VERSIONU=1_2_5_beta03272005-c
-VERSIOND=1.2.5_beta03272005-c
-VERSIONU=1_2_5
-VERSIOND=1.2.5
+VERSIONU=1_2_6-beta04122005-gsak
+VERSIOND=1.2.6_beta04122005-gsak
+VERSIONU=1_2_5
+VERSIOND=1.2.5
 
 release:
        cvs commit
index 17927d0136ff05ff0d0ee049adf37c1896dce2c7..6b09650d0a9a3381dd3e17ceab4ea42fa751eef5 100644 (file)
@@ -397,7 +397,7 @@ data_write(void)
            if (global_opts.synthesize_shortnames && waypointp->description) {
                if (waypointp->shortname)
                    xfree(waypointp->shortname);
-               waypointp->shortname = mkshort(mkshort_wr_handle, waypointp->description);
+               waypointp->shortname = mkshort_from_wpt(mkshort_wr_handle, waypointp);
            }
            bh->wpt_name = waypointp->shortname;
            bh ++;
index 42d67b9852ff80f64b1fbceee74ae3a497975f5b..02cb3ebf8b2db9546d16e333db549faec065fab4 100644 (file)
@@ -854,8 +854,8 @@ xcsv_waypt_pr(const waypoint *wpt)
     
     if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) {
         if (wpt->description) {
-            if (global_opts.synthesize_shortnames)
-                shortname = mkshort(xcsv_file.mkshort_handle, wpt->description);
+            if (global_opts.synthesize_shortnames) 
+               shortname = mkshort_from_wpt(xcsv_file.mkshort_handle, wpt);
             else
                 shortname = csv_stringclean(wpt->description, xcsv_file.badchars);
         } else {
index e979c6d8615ef948960815395a593d9dc5dd41b7..c3e9b54dc963d89c74c21b3bee374887b256d1d0 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2002 Robert Lipe, robertlipe@usa.net
+    Copyright (C) 2002, 2003, 2004, 2005  Robert Lipe, robertlipe@usa.net
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -330,6 +330,7 @@ void *MKSHORT_NEW_HANDLE(DEBUG_PARAMS);
 #define mkshort( a, b) MKSHORT(a,b,__FILE__, __LINE__)
 #define mkshort_new_handle() MKSHORT_NEW_HANDLE(__FILE__,__LINE__)
 #endif
+char *mkshort_from_wpt(void *h, const waypoint *wpt);
 void mkshort_del_handle(void *h);
 void setshort_length(void *, int n);
 void setshort_badchars(void *, const char *);
index 4433a7fa1db26a97239b0e9c1d81ed8b0e40661f..ae648d093f08cb95ba6adbc88a7dd747517e50b0 100644 (file)
@@ -118,7 +118,7 @@ gpsutil_disp(const waypoint *wpt)
 
        fprintf(file_out, "%-8s %08.3f%c %09.3f%c %07.0f%c %-30.30s %s\n",
                 global_opts.synthesize_shortnames ?
-                        mkshort(mkshort_handle, wpt->description) : 
+                        mkshort_from_wpt(mkshort_handle, wpt) : 
                        wpt->shortname,
                fabs(lat),
                lat < 0.0 ? 'S' : 'N',
index 1eb5d7021bd9aa4e8f49d731c426b0a23db78ca3..9450e2a59b0c2a72837ccfaee404ac194c7091f8 100644 (file)
@@ -52,7 +52,6 @@ static int input_string_len = 0;
 
 static time_t file_time;
 
-static char *gsshortnames = NULL;
 static char *snlen = NULL;
 static char *suppresswhite = NULL;
 static char *urlbase = NULL;
@@ -658,11 +657,7 @@ gpx_end(void *data, const char *el)
                wpt_tmp = NULL;
                break;
        case tt_cache_name:
-               if (gsshortnames) {
-                       if (wpt_tmp->notes)
-                               xfree(wpt_tmp->notes);
-                       wpt_tmp->notes = xstrdup(cdatastrp);
-               }
+               wpt_tmp->notes = xstrdup(cdatastrp);
                break;
        case tt_cache_container:
                wpt_tmp->gc_data.container = gs_mkcont(cdatastrp);
@@ -1321,9 +1316,6 @@ gpx_write(void)
 
 static
 arglist_t gpx_args[] = {
-       { "gsshortnames", &gsshortnames, 
-               "Prefer shorter descriptions from Groundspeak files",
-               NULL, ARGTYPE_BOOL },
        { "snlen", &snlen, "Length of generated shortnames", 
                NULL, ARGTYPE_INT },
        { "suppresswhite", &suppresswhite, 
index 1f61d396687c1ddf79274ae3caff3d91940c71e7..0b4c5dcbfb5193161befcc6fe55b81cd08230a66 100644 (file)
@@ -83,7 +83,7 @@ html_disp(const waypoint *wpt)
        fprintf(file_out, "<hr>\n");
        fprintf(file_out, "<a name=\"%s\"></a><table width=\"100%%\"><tr><td>\n", wpt->shortname);
        fprintf(file_out, "<h3 class=\"waypoint\">%s - %c%d&deg;%06.3f %c%d&deg;%06.3f (%ld%c %6.0f %7.0f)",
-               (global_opts.synthesize_shortnames) ? mkshort(mkshort_handle, wpt->description) : wpt->shortname,
+               (global_opts.synthesize_shortnames) ? mkshort_from_wpt(mkshort_handle, wpt) : wpt->shortname,
                wpt->latitude < 0 ? 'S' : 'N',  latint, 60.0 * (fabs(wpt->latitude) - latint), 
                wpt->longitude < 0 ? 'W' : 'E', lonint, 60.0 * (fabs(wpt->longitude) - lonint),
                utmz, utmzc, utme, utmn);
index e0fac3c955d53e0273a8a0dd86dd1ef0b08e211d..12b78e375c4d8a8236cb61aeddca7032127ba494 100644 (file)
@@ -300,7 +300,7 @@ lowranceusr_waypt_pr(const waypoint *wpt)
        /* Try and make sure we have a name */
        if ((! wpt->shortname) || global_opts.synthesize_shortnames) {
                if (wpt->description && global_opts.synthesize_shortnames) {
-                       name = mkshort(mkshort_handle, wpt->description);
+                       name = mkshort_from_wpt(mkshort_handle, wpt);
                } else if (wpt->shortname) {
                        name = xstrdup(wpt->shortname);
                } else if (wpt->description) {
index bc0a8183a48044debe076c0498a4da03f51bcb57..8e9370dc96c7844f6518e8fe3edd17bba3f506b1 100644 (file)
@@ -145,7 +145,7 @@ my_writewpt(const waypoint *wpt)
        char *vdata;
        time_t tm_t;
        const char *sn = global_opts.synthesize_shortnames ?
-               mkshort(mkshort_handle, wpt->description) :
+               mkshort_from_wpt(mkshort_handle, wpt) :
                wpt->shortname;
 
        rec = xcalloc(sizeof(*rec)+56,1);
index 2141314cd36efb4ef8ea356d871e81aae3d97b3d..c094c68a54776ee8e847d7511c46a1d7151621b0 100644 (file)
@@ -1168,7 +1168,7 @@ mag_waypt_pr(const waypoint *waypointp)
        const char *icon_token=NULL;
        char *owpt;
        char *odesc;
-       char *isrc;
+       char *isrc = NULL;
 
        ilat = waypointp->latitude;
        ilon = waypointp->longitude;
@@ -1197,7 +1197,7 @@ mag_waypt_pr(const waypoint *waypointp)
 
        isrc = waypointp->notes ? waypointp->notes : waypointp->description;
        owpt = global_opts.synthesize_shortnames ?
-                        mkshort(mkshort_handle, isrc) : waypointp->shortname;
+                        mkshort_from_wpt(mkshort_handle, waypointp) : waypointp->shortname;
        odesc = isrc ? isrc : "";
        owpt = mag_cleanse(owpt);
 
index 0a70623378c9538ef365c95a2e549181ce90ccb2..fa538c342138e009b75701b5ac554ef8ebdd59f5 100644 (file)
@@ -316,7 +316,7 @@ mapsend_waypt_pr(const waypoint *waypointp)
        static int cnt = 0;
        const char *iconp = NULL;
        const char *sn = global_opts.synthesize_shortnames ? 
-               mkshort(mkshort_handle, waypointp->description) :
+               mkshort_from_wpt(mkshort_handle, waypointp) :
                waypointp->shortname;
        char *tmp;
 
index 8edef7683a41813265cbf5e26c55b61f05c876ee..fc3304ba150e8d7148c4afbe17edc71288e8895e 100644 (file)
@@ -287,22 +287,6 @@ mkshort(void *h, const char *istring)
                ostring = nstring;
        }
 
-       /*
-        * Look at the back of the string for " by BLAH" and whack 
-        * it there.
-        */
-       nstring = xxstrdup(ostring, file, line);
-       l = strlen (nstring);
-       while (l > 0) {
-               if (case_ignore_strncmp(&nstring[l], " by ",4) == 0)  {
-                       nstring[l] = 0;
-                       break;
-               }
-               l --;
-       }
-       xfree(ostring);
-       ostring = nstring;
-
        /* Eliminate leading whitespace in all cases */
        while (ostring[0] && isspace(ostring[0])) {
                /* If orig string has N bytes, we want to copy N-1 bytes
@@ -417,6 +401,32 @@ mkshort(void *h, const char *istring)
        return ostring;
 }
 
+/*
+ * As above, but arg list is a waypoint so we can centralize
+ * the code that considers the alternate sources.
+ */
+char *
+mkshort_from_wpt(void *h, const waypoint *wpt)
+{
+       /* This probably came from a Groundspeak Pocket Query
+        * so use the 'cache name' instead of the description field
+        * which contains placer name, diff, terr, and generally way
+        * more stuff than should be in any one field...
+        */
+       if (wpt->gc_data.diff && wpt->gc_data.terr && wpt->notes) {
+               return mkshort(h, wpt->notes);
+       }
+
+       if (wpt->description) {
+               return mkshort(h, wpt->description);
+       }
+
+       if (wpt->notes) {
+               return mkshort(h, wpt->notes);
+       }
+}
+
+
 #if 0
 char *foo[] =  {
 "VwthPst# 3700.706N 08627.588W 0000000m View the Past #2              ",
index 4debbb81d54b4858432d255f23f28b36cee2a580..d9471e5cd6941efc66c478fff0761beabae92d6a 100644 (file)
@@ -626,7 +626,7 @@ ozi_waypt_pr(const waypoint * wpt)
     if ((!wpt->shortname) || (global_opts.synthesize_shortnames)) {
         if (wpt->description) {
             if (global_opts.synthesize_shortnames)
-                shortname = mkshort(mkshort_handle, wpt->description);
+                shortname = mkshort_from_wpt(mkshort_handle, wpt);
             else
                 shortname = csv_stringclean(wpt->description, ",");
         } else {
index cda37d95bae1ef43a51c3595a169e0cb990290f7..5e82f5aea393bdb9b7c5393bdc26c2951541dd6c 100644 (file)
@@ -423,13 +423,13 @@ palmdoc_disp(const waypoint *wpt)
         char bookmarktext[17];
 
         if ( bmid ) {
-               char * s = mkshort(mkshort_bookmark_handle, wpt->description);
+               char * s = mkshort_from_wpt(mkshort_bookmark_handle, wpt);
                sprintf( bookmarktext, "%6s:%9s", 
                        wpt->shortname?wpt->shortname:"",s);
                xfree(s);
        }
        else {
-               char * s = mkshort(mkshort_bookmark_handle, wpt->description);
+               char * s = mkshort_from_wpt(mkshort_bookmark_handle, wpt);
                sprintf( bookmarktext, "%16s", s);
                xfree(s);
        }       
@@ -448,7 +448,7 @@ palmdoc_disp(const waypoint *wpt)
        strftime(tbuf, sizeof(tbuf), "%d-%b-%Y", localtime(&tm));
 
        docprintf(300, "%-16s  %c%d %06.3f  %c%d %06.3f  (%ld%c %6.0f %7.0f)",
-               (global_opts.synthesize_shortnames) ? mkshort(mkshort_handle, wpt->description) : wpt->shortname,
+               (global_opts.synthesize_shortnames) ? mkshort_from_wpt(mkshort_handle, wpt) : wpt->shortname,
                wpt->latitude < 0 ? 'S' : 'N',  abs(latint), 60.0 * (fabs(wpt->latitude) - latint), 
                wpt->longitude < 0 ? 'W' : 'E', abs(lonint), 60.0 * (fabs(wpt->longitude) - lonint),
                utmz, utmzc, utme, utmn);
index 132c1690d7219c59f291e9960cc382776471b2c2..fb4f87276feafa6ddeea574d6d5c4a8ba2719b66 100644 (file)
@@ -194,7 +194,7 @@ gpsutil_disp(const waypoint *wpt)
 
        fprintf(file_out, "W  %-6.6s %c%08.5f %c%011.5f %s %5d %-40.40s %5e  %d\n",
                 global_opts.synthesize_shortnames ?
-                        mkshort(mkshort_handle, wpt->description) : 
+                        mkshort_from_wpt(mkshort_handle, wpt) : 
                        wpt->shortname,
                lat < 0.0 ? 'S' : 'N',
                fabs(lat),
index c621be61ea3fbd1aab3fbe40de7e62ad1e598781..b3a04e65097e908b6986c02e3fdbd49c6ff95d4b 100644 (file)
@@ -327,7 +327,7 @@ psp_waypt_pr(const waypoint *wpt)
         if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) {
             if (wpt->description) {
                 if (global_opts.synthesize_shortnames)
-                    shortname = mkshort(mkshort_handle, wpt->description);
+                    shortname = mkshort_from_wpt(mkshort_handle, wpt);
                 else
                     shortname = xstrdup(wpt->description);
             } else {
index a80761b7d5d38d31683249944e4a195de92cd1bb..56b272c76e2c664790fb90b60a29a0fbada74eca 100644 (file)
@@ -82,7 +82,7 @@ text_disp(const waypoint *wpt)
        strftime(tbuf, sizeof(tbuf), "%d-%b-%Y", localtime(&tm));
 
        fprintf(file_out, "%-16s  %c%d %06.3f  %c%d %06.3f  (%ld%c %6.0f %7.0f)",
-               (global_opts.synthesize_shortnames) ? mkshort(mkshort_handle, wpt->description) : wpt->shortname,
+               (global_opts.synthesize_shortnames) ? mkshort_from_wpt(mkshort_handle, wpt) : wpt->shortname,
                wpt->latitude < 0 ? 'S' : 'N',  abs(latint), 60.0 * (fabs(wpt->latitude) - latint), 
                wpt->longitude < 0 ? 'W' : 'E', abs(lonint), 60.0 * (fabs(wpt->longitude) - lonint),
                utmz, utmzc, utme, utmn);
index 2e1ed9a985f23593d0c48c9b66a78ebc057de666..4940f20cc0c7e5c02f0253052082769cec3ddbf6 100644 (file)
@@ -180,7 +180,7 @@ tmpro_waypt_pr(const waypoint * wpt)
        if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) {
         if (wpt->description) {
             if (global_opts.synthesize_shortnames)
-                shortname = mkshort(mkshort_handle, wpt->description);
+                shortname = mkshort_from_wpt(mkshort_handle, wpt);
             else
                 shortname = csv_stringclean(wpt->description, ",\"");
         } else {
index e12807d86774c0bfd47af5facd7508d20475ec5c..c30dec2554945b27c4aae90ffd811acf27afea30 100644 (file)
@@ -225,7 +225,7 @@ tpg_waypt_pr(const waypoint *wpt)
         if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) {
             if (wpt->description) {
                 if (global_opts.synthesize_shortnames)
-                    shortname = mkshort(mkshort_handle, wpt->description);
+                    shortname = mkshort_from_wpt(mkshort_handle, wpt);
                 else
                     shortname = xstrdup(wpt->description);
             } else {